/*--------------------------------------------------------------------------------------*\
**
** adv_trading_post.cpp
**
** Heroes IV
** Copyright 2000, The 3DO Company
**
\*--------------------------------------------------------------------------------------*/

#include "precompiled.h"
#pragma warning( disable: 4786 )

#include "adv_trading_post.h"

#include "adv_object_type.h"
#include "adventure_frame.h"
#include "adventure_sounds.h"
#include "army.h"
#include "dialog_marketplace.h"
#include "external_string.h"
#include "material_names.h"
#include "music.h"
#include "object_registration.h"
#include "sound.h"
#include "sound_cache.h"
// ---------------------------------------------------------------
// unnamed namespace
// ---------------------------------------------------------------

namespace
{

	t_object_registration< t_adv_trading_post > k_registration( k_adv_object_trading_post );

} // unnamed namespace

// Always 1:k_trading_post_ratio_efficiency
static int const k_trading_post_ratio_efficiency = 2;

t_adv_trading_post::t_adv_trading_post( std::string const& model_name)
          : t_stationary_adventure_object( model_name )
{
}

static t_external_string const k_text_trading_post_initial ( "trading_post.misc" );

void t_adv_trading_post::activate_trigger( t_army* army, t_adv_map_point const& point, 
		                                   t_direction direction, t_adventure_frame* frame )
{
	t_dialog_marketplace * marketplace_dialog = new t_dialog_marketplace( frame );

	marketplace_dialog->init_dialog( frame, frame, get_text("name"), k_text_trading_post_initial, //get_text("Initial"),
                    k_trading_post_ratio_efficiency );
	t_sound_cache music = get_music_playing();
	stop_music();
	get_dialog_sound( k_dialog_sound_marketplace )->play( get_sound_volume() );
	marketplace_dialog->run_modal();
	play_music( music );
}

